#rain <- scan("http://robjhyndman.com/tsdldata/hurst/precip1.dat",skip=1)
#rainseries <- ts(rain,start=c(1813)) %>% as.data.frame() %>% mutate(time=1813:1912)
#
#ggplot(rainseries,aes(x=time,y=x))+geom_point()+geom_path()+geom_smooth()
#pacman::p_load(ggplot2)
#set.seed(100)
#data <- data.frame(x=1813:1912,y=runif(100,min=-1,max=2))
#
##data <- ts(data$y,frequency=12,start = c(1813,1)) %>% as.data.frame()
#
#ggplot(data,aes(x=x,y=y))+geom_point()+geom_path()+geom_smooth()

pacman::p_load(ggplot2,matlab,pracma)
#data <- read.delim("E:/projects/Lysimeter_Systems/src/output2/A13-l.xls")
#
#mean <- data$mean
#x <- seq_along(mean)
#
#drawdata <- data.frame(t=x,weight_s=mean)
#
#ggplot(drawdata,aes(x=t,y=weight_s))+geom_smooth()+geom_point()

#set.seed(100)
#
#x <- seq(0, 10, 0.1); y <- sin(x) + rnorm(101)   #x的值必须排序
#
#plot(x, y);    #做散点图
#
#a <- lowess(x, y)
#lines(a)
#lines(x,predict(loess(y~x)))
#k <- loess(y~x)

#lines(lowess(x, y));   #利用lowess做回归曲线
#lines(x, predict(loess(y ~ x)));   #利用loess做回归曲线，predict是取回归预测值
#z <- loess(y ~ x); lines(x, z$fit);   #利用loess做

data <- read.delim("E:/projects/Lysimeter_Systems/src/output2/A13-l.xls")
Time <- data$Time ;Weight_s <- data$mean
dd <- data.frame(Time,Weight_s)
plot(Time,Weight_s)

f <- sin
xs <- seq(-pi, pi, length.out = 100)
ys <- f(xs)
y1 <- fderiv(sin, 1:24, n = 1, method = "forward")
